﻿using System;
using Newtonsoft.Json;
using System.Text;

namespace Serializer.Implementation
{
    public class JsonSerializerISerializer<T> : ISerializer<T>
    {
        public byte[] Serialize(T instance)
        {
            var str = JsonConvert.SerializeObject(instance);
            var bytes = System.Text.Encoding.UTF8.GetBytes(str);
            return bytes;
        }
        public T Deserialize(byte[] instance)
        {

            var str = System.Text.Encoding.UTF8.GetString(instance);

            var obj = JsonConvert.DeserializeObject<T>(str);

            return obj;
        }

      
    }

  
}
